package com.example.jiemian;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
import android.widget.ScrollView;

public class Webview_zidingyi extends WebView {  
  
    private ScrollListener mListener;  
  
    public static interface ScrollListener {  
        public void scrollOritention(int oritention);  
    }  
  
    /** 
     * ScrollView�������ϻ��� 
     */  
    public static final int SCROLL_UP = 0x01;  
  
    /** 
     * ScrollView�������»��� 
     */  
    public static final int SCROLL_DOWN = 0x10;  
  
    /** 
     * ��С�Ļ������� 
     */  
    private static final int SCROLLLIMIT = 20;  
  
    public Webview_zidingyi(Context context) {  
        super(context, null);  
    }  
  
    public Webview_zidingyi(Context context, AttributeSet attrs) {  
        super(context, attrs, 0);  
    }  
  
    public Webview_zidingyi(Context context, AttributeSet attrs,  
            int defStyle) {  
        super(context, attrs, defStyle);  
    }  
  
    @Override  
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {  
        super.onScrollChanged(l, t, oldl, oldt);  
  
        if (oldt > t && oldt - t > SCROLLLIMIT) {// ����  
            if (mListener != null)  
                mListener.scrollOritention(SCROLL_DOWN);  
           
        } else if (oldt < t && t - oldt > SCROLLLIMIT) {// ����  
            if (mListener != null)  
                mListener.scrollOritention(SCROLL_UP);         
        }  
    }  
  
    public void setScrollListener(ScrollListener l) {  
        this.mListener = l;  
    }  
}  